/**
 * @lastUpdateBy : 韩怡婷
 * @description: image数据管理相关api
 */
import qs from 'qs'; // 导入qs模块 增加了一些安全性的查询字符串解析和序列化字符串的库
export default {
	/**
	 * @description: 获取数据
	 * @param {Object} params 参数
	 * @return {Promise}
	 */
	getImageStore(params) {
		return new Promise((resolve, reject) => {
			agcim.net.axiosWraper
				.getData(
					agcim.net.apiPath.io_imagestore_getByDomainAndUsage,
					params
				)
				.then(
					(response) => {
						if (response.success) {
							resolve(response);
						} else {
							reject(response);
						}
					},
					(error) => {
						reject(error);
					}
				);
		});
	},


	// /**
	//  * @description: 新增数据
	//  * @param {Object} params
	//  * @return {Promise}
	//  */
	// saveImageStore(params) {
	// 	return new Promise((resolve, reject) => {
	// 		agcim.net.axiosWraper
	// 			.getDataByPost(
	// 				agcim.net.apiPath.io_imagestore_save,
	// 				qs.stringify(params)
	// 			)
	// 			.then(
	// 				(response) => {
	// 					if (response.success) {
	// 						resolve(response);
	// 					} else {
	// 						reject(response);
	// 					}
	// 				},
	// 				(error) => {
	// 					reject(error);
	// 				}
	// 			);
	// 	});
	// },
	/**
		 * @description: 新增数据 新
		 * @param {Object} params
		 * @return {Promise}
		 */
	saveImageStore(params) {
		return new Promise((resolve, reject) => {
			agcim.net.axiosWraper
				.getDataByPost(
					agcim.net.apiPath.io_imagestore_add,
					qs.stringify(params)
				)
				.then(
					(response) => {
						if (response.success) {
							resolve(response);
						} else {
							reject(response);
						}
					},
					(error) => {
						reject(error);
					}
				);
		});
	},

	// /**
	//  * @description: 更新数据
	//  * @param {Object} params
	//  * @return {Promise}
	//  */
	// updateImageStore(params) {
	// 	return new Promise((resolve, reject) => {
	// 		agcim.net.axiosWraper
	// 			.getDataByPost(
	// 				agcim.net.apiPath.io_imagestore_update,
	// 				qs.stringify(params)
	// 			)
	// 			.then(
	// 				(response) => {
	// 					if (response.success) {
	// 						resolve(response);
	// 					} else {
	// 						reject(response);
	// 					}
	// 				},
	// 				(error) => {
	// 					reject(error);
	// 				}
	// 			);
	// 	});
	// },
	/**
	 * @description: 更新数据 新
	 * @param {Object} params
	 * @return {Promise}
	 */
	updateImageStore(params) {
		return new Promise((resolve, reject) => {
			agcim.net.axiosWraper
				.getDataByPost(
					agcim.net.apiPath.io_imagestore_update,
					qs.stringify(params)
				)
				.then(
					(response) => {
						if (response.success) {
							resolve(response);
						} else {
							reject(response);
						}
					},
					(error) => {
						reject(error);
					}
				);
		});
	},


	/**
	 * 
	 * @param {Object} params 
	 * @returns {Promise}
	 */
	deleteImageStore(params) {
		return new Promise((resolve, reject) => {
			agcim.net.axiosWraper
				.delete(agcim.net.apiPath.io_imagestore_deleteById, params)
				.then(
					(response) => {
						if (response.success) {
							resolve(response);
						} else {
							reject(response);
						}
					},
					(error) => {
						reject(error);
					}
				);
		});
	},
	/**
	* 
	* @param {Object} params 
	* @returns {Promise}
	*/
	uploadImage(params) {
		return new Promise((resolve, reject) => {
			agcim.net.axiosWraper
				.getDataByPost(agcim.net.apiPath.io_imagestore_updateImage, params)
				.then(
					(response) => {
						if (response.success) {
							resolve(response);
						} else {
							reject(response);
						}
					},
					(error) => {
						reject(error);
					}
				);
		});
	},
	/**
	 * @description: 根据目录id分页获取该目录下的权限可视数据
	 * @param {Object} params 参数id
	 * @return {Promise}
	 */
	selectAuthPageByDirId(params) {
		return new Promise((resolve, reject) => {
			agcim.net.axiosWraper
				.getData(
					agcim.net.apiPath.io_imagestore_selectAuthPageByDirId,
					params
				)
				.then(
					(response) => {
						if (response.success) {
							resolve(response);
						} else {
							reject(response);
						}
					},
					(error) => {
						reject(error);
					}
				);
		});
	},
	/**
	 * @description: 拖拽排序
	 * @param {Object} params 参数
	 * @return {Promise}
	 */
	dragSort(params) {
		return new Promise((resolve, reject) => {
			agcim.net.axiosWraper
				.getDataByPost(
					agcim.net.apiPath.io_imagestore_dragSort,
					params
				)
				.then(
					(response) => {
						if (response.success) {
							resolve(response);
						} else {
							reject(response);
						}
					},
					(error) => {
						reject(error);
					}
				);
		});
	},
	/**
	 * @description: 查询默认视点
	 * @param {Object} params 参数
	 * @return {Promise}返回优先级最高的默认视点
	 */
	selectInitialSpotByUser(params) {
		return new Promise((resolve, reject) => {
			agcim.net.axiosWraper
				.getData(
					agcim.net.apiPath.io_imagestore_selectInitialSpotByUser,
					params
				)
				.then(
					(response) => {
						if (response.success) {
							resolve(response);
						} else {
							reject(response);
						}
					},
					(error) => {
						reject(error);
					}
				);
		});
	},
		/**
	 * @description: 根据目录code分页获取该目录下的权限可视数据
	 * @param {Object} params 参数dirCode&row&page
	 * @return {Promise}
	 */
		 selectAuthPageByDirCode(params) {
			return new Promise((resolve, reject) => {
				agcim.net.axiosWraper
					.getData(
						agcim.net.apiPath.io_imagestore_selectAuthPageByDirCode,
						params
					)
					.then(
						(response) => {
							if (response.success) {
								resolve(response);
							} else {
								reject(response);
							}
						},
						(error) => {
							reject(error);
						}
					);
			});
		},
};
